//! # RustCloud - 高性能Rust微服务框架
//! 
//! RustCloud是一个全面的微服务框架，提供服务注册与发现、负载均衡、熔断器、
//! 代理、监控、追踪、日志等完整的微服务治理能力。
//! 
//! ## 主要特性
//! 
//! - 🚀 **高性能**: 基于Rust的零成本抽象和异步运行时
//! - 🔧 **模块化**: 可插拔的组件架构，按需使用
//! - 📊 **可观测性**: 内置指标、追踪、日志的完整观测性支持
//! - 🛡️ **可靠性**: 熔断器、重试、故障转移等容错机制
//! - 🌐 **多协议**: 支持HTTP、gRPC等多种协议
//! - 📈 **弹性**: 智能负载均衡和自动扩展
//! 
//! ## 快速开始
//! 
//! ```rust,no_run
//! use rustcloud::RustCloudBuilder;
//! 
//! #[tokio::main]
//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
//!     let cloud = RustCloudBuilder::new("my-service")
//!         .with_registry("nacos://127.0.0.1:8848")
//!         .with_load_balancer("round_robin")
//!         .with_circuit_breaker()
//!         .with_metrics()
//!         .with_tracing()
//!         .build()
//!         .await?;
//!     
//!     cloud.start().await?;
//!     Ok(())
//! }
//! ```

pub mod config;
pub mod builder;
pub mod advanced_builder;
pub mod framework;
pub mod prelude;
pub mod di;
pub mod lifecycle;
pub mod observability;
pub mod performance;
pub mod performance_monitor;

// 内部模块
mod defaults;

// 重新导出核心类型
pub use rustcloud_core::*;

// 重新导出可用的组件
// pub use rustcloud_registry as registry;
// pub use rustcloud_loadbalancer as loadbalancer;
// pub use rustcloud_circuit_breaker as circuit_breaker;
// pub use rustcloud_proxy as proxy;
// pub use rustcloud_transport as transport;
// pub use rustcloud_config as configuration;
// pub use rustcloud_metrics as metrics;
// pub use rustcloud_logging as logging;

// 主要构建器和框架类型
pub use builder::{SimpleRustCloudBuilder as RustCloudBuilder};
// pub use builder::ConfigurationBuilder;
// pub use advanced_builder::{AdvancedRustCloudBuilder, BuilderPlugin, ConfigValidator, EnvironmentAdapter, BuildHook};
// pub use framework::{RustCloudFramework, FrameworkState, HealthStatus};
pub use config::{RustCloudConfig, ComponentConfig};
// pub use di::{DIContainer, ComponentLifecycle, ComponentMetadata};
pub use lifecycle::{LifecycleManager, LifecycleComponent, LifecyclePhase};
// pub use observability::{ObservabilityManager, ObservabilityConfig, ObservabilityContext, LogLevel, UnifiedObservabilityManager, ObservabilityManagerBuilder, TracingProcessor, LogManager};
// pub use performance::{ConnectionPool, MemoryManager, AsyncTaskPool, ConnectionPoolConfig, GcConfig};
// pub use performance_monitor::{PerformanceMonitor, SystemMetrics, PerformanceAlert, PerformanceSummary};

/// RustCloud框架的默认错误类型
pub type RustCloudError = rustcloud_core::ServiceError;

/// RustCloud框架的结果类型
pub type RustCloudResult<T> = rustcloud_core::ServiceResult<T>;

/// 框架版本信息
pub const VERSION: &str = env!("CARGO_PKG_VERSION");

/// 获取框架版本
pub fn version() -> &'static str {
    VERSION
}

/// 框架默认配置
pub mod defaults {
    /// 默认服务端口
    pub const DEFAULT_PORT: u16 = 8080;
    
    /// 默认健康检查端口
    pub const DEFAULT_HEALTH_PORT: u16 = 8081;
    
    /// 默认指标端口
    pub const DEFAULT_METRICS_PORT: u16 = 9090;
    
    /// 默认配置文件名
    pub const DEFAULT_CONFIG_FILE: &str = "rustcloud.toml";
    
    /// 默认日志级别
    pub const DEFAULT_LOG_LEVEL: &str = "info";
    
    /// 默认连接超时时间（秒）
    pub const DEFAULT_CONNECT_TIMEOUT: u64 = 10;
    
    /// 默认请求超时时间（秒）
    pub const DEFAULT_REQUEST_TIMEOUT: u64 = 30;
    
    /// 默认重试次数
    pub const DEFAULT_RETRY_ATTEMPTS: u32 = 3;
}

/// 常用类型和trait的便捷导入
pub mod prelude {
    pub use crate::{
        RustCloudBuilder,
        RustCloudConfig,
        RustCloudResult,
        RustCloudError,
    };
    
    pub use crate::config::ComponentConfig;
}